<template>
  <PageWrapper contentFullHeight fixedHeight>
    <VxeBasicTable class="w-full h-full" ref="tableRef" v-bind="gridOptions">
      <template #action="{ row }">
        <a-button type="link" size="small" @click="handleView(row)">
          <template #icon> 查看详情</template>
        </a-button>
      </template>
    </VxeBasicTable>
    <DetailsModal @register="registerModal" />
  </PageWrapper>
</template>

<script lang="ts" setup>
  import { ref, reactive } from 'vue';
  import { Icon } from '@gui-pkg/components';
  import { PageWrapper, BasicTableProps, useModal } from '@gui-pkg/antdcomponents';
  import { VxeBasicTable, VxeGridInstance } from '@gui-pkg/antdcomponents';
  import { columns,searchFormSchema } from './records.data';
  import { getWarnmsgPage } from '@/api/alerts/warningSendRecords';
  import DetailsModal from './DetailsModal';

  defineOptions({ name: 'WarningSendRecords' });

  const [registerModal, { openModal }] = useModal();
  const tableRef = ref<VxeGridInstance>();
  const gridOptions = reactive<BasicTableProps>({
    id: tableRef.value,
    keepSource: true,
    editConfig: { trigger: 'click', mode: 'cell', showStatus: true },
    columns: columns,
    toolbarConfig: {
      className: "vxe-toolbarConfig",
    },
    height: 'auto',
    formConfig: {
      enabled: true,
      className: "vxe-formConfig",
      items: searchFormSchema,
    },
    proxyConfig: {
      ajax: {
        query: async ({ page, form }) => {
          const tableListData = await getWarnmsgPage({
            pageNum: page.currentPage,
            pageSize: page.pageSize,
            beginTime:form.sendTime==null?"":form.sendTime[0],
            endTime:form.sendTime==null?"":form.sendTime[1],
            isDirect:1,
            town:form.town,
            stnm:form.stnm,
          });
          console.log(tableListData, 'tableListData');
          return { list: tableListData.records,total:tableListData.total };
        },
      },
    },
  });

  const handleView = (data)=> {
    openModal(true, {
      record: data,
    });
  }
</script>

